1 /* 2 * Copyright (c) 2013-2014 - Mauro Carvalho Chehab <m.chehab@samsung.com> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation version 2.1 of the License. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html 17 * 18 */ 19 20 module libdvbv5_d.desc_atsc_service_location; 21 22 import libdvbv5_d.descriptors: dvb_desc; 23 import libdvbv5_d.dvb_fe: dvb_v5_fe_parms; 24 25 extern (C): 26 27 /** 28 * @file desc_atsc_service_location.h 29 * @ingroup descriptors 30 * @brief Provides the descriptors for ATSC service location 31 * @copyright GNU Lesser General Public License version 2.1 (LGPLv2.1) 32 * @author Mauro Carvalho Chehab 33 * 34 * @par Relevant specs 35 * The descriptor described herein is defined at: 36 * - ATSC A/53 37 * 38 * @see http://www.etherguidesystems.com/help/sdos/atsc/semantics/descriptors/ServiceLocation.aspx 39 * 40 * @par Bug Report 41 * Please submit bug reports and patches to linux-media@vger.kernel.org 42 */ 43 44 /** 45 * @struct atsc_desc_service_location_elementary 46 * @ingroup descriptors 47 * @brief service location elementary descriptors 48 * 49 * @param stream_type stream type 50 * @param elementary_pid elementary pid 51 * @param ISO_639_language_code ISO 639 language code 52 */ 53 struct atsc_desc_service_location_elementary 54 { 55 align (1): 56 57 ubyte stream_type; 58 59 union 60 { 61 align (1): 62 63 ushort bitfield; 64 65 struct 66 { 67 import std.bitmanip : bitfields; 68 align (1): 69 70 mixin(bitfields!( 71 ushort, "elementary_pid", 13, 72 ushort, "reserved", 3)); 73 } 74 } 75 76 char[3] ISO_639_language_code; 77 } 78 79 /** 80 * @struct atsc_desc_service_location 81 * @ingroup descriptors 82 * @brief Describes the elementary streams inside a PAT table for ATSC 83 * 84 * @param type descriptor tag 85 * @param length descriptor length 86 * @param next pointer to struct dvb_desc 87 * @param elementary pointer to struct atsc_desc_service_location_elementary 88 * @param pcr_pid PCR pid 89 * @param number_elements number elements 90 */ 91 struct atsc_desc_service_location 92 { 93 align (1): 94 95 ubyte type; 96 ubyte length; 97 dvb_desc* next; 98 99 atsc_desc_service_location_elementary* elementary; 100 101 union 102 { 103 align (1): 104 105 ushort bitfield; 106 107 struct 108 { 109 import std.bitmanip : bitfields; 110 align (1): 111 112 mixin(bitfields!( 113 ushort, "pcr_pid", 13, 114 ushort, "reserved", 3)); 115 } 116 } 117 118 ubyte number_elements; 119 } 120 121 // struct dvb_v5_fe_parms; 122 123 /** 124 * @brief Initializes and parses the service location descriptor 125 * @ingroup descriptors 126 * 127 * @param parms struct dvb_v5_fe_parms pointer to the opened device 128 * @param buf buffer containing the descriptor's raw data 129 * @param desc pointer to struct dvb_desc to be allocated and filled 130 * 131 * This function allocates a the descriptor and fills the fields inside 132 * the struct. It also makes sure that all fields will follow the CPU 133 * endianness. Due to that, the content of the buffer may change. 134 * 135 * @return On success, it returns the size of the allocated struct. 136 * A negative value indicates an error. 137 */ 138 int atsc_desc_service_location_init ( 139 dvb_v5_fe_parms* parms, 140 const(ubyte)* buf, 141 dvb_desc* desc); 142 143 /** 144 * @brief Prints the content of the service location descriptor 145 * @ingroup descriptors 146 * 147 * @param parms struct dvb_v5_fe_parms pointer to the opened device 148 * @param desc pointer to struct dvb_desc 149 */ 150 void atsc_desc_service_location_print ( 151 dvb_v5_fe_parms* parms, 152 const(dvb_desc)* desc); 153 154 /** 155 * @brief Frees all data allocated by the service location descriptor 156 * @ingroup descriptors 157 * 158 * @param desc pointer to struct dvb_desc to be freed 159 */ 160 void atsc_desc_service_location_free (dvb_desc* desc);